﻿<!doctype html>
<html>

<head>
      <title>API接口方法说明</title>

      <script type="text/javascript" src="/Utilities/Scripts/polyfill.min.js"></script>
      <script type="text/javascript" src="/Utilities/Scripts/axios_min.js"></script>
      <script type="text/javascript" src="/Utilities/Scripts/api.js"></script>
      <script type="text/javascript" src="/Utilities/Scripts/vue.min.js"></script>
      <script type="text/javascript" src="/Utilities/Scripts/vue-router.js"></script>
      <script type="text/javascript" src="/Utilities/ElementUi/index.js"></script>
      <link rel="stylesheet" type="text/css" href="/Utilities/ElementUi/index.css" />


      <link href="Styles/index.css" rel="stylesheet" type="text/css" />
      <meta charset="utf-8">
</head>

<body>

      <section id="apiinfo">
            <menu id="menu">
                  <div class="tit"> <i class="el-icon-set-up"></i>API list
                        <div class="searchbox"> <i class="el-icon-search"></i>
                              <form> <input type="text" name="search" id="apisearch" autofocus v-model="apisearch" />
                              </form>
                        </div>
                  </div>
                  <dl>
                        <dd v-for="(u,i) in list">
                              <methods :apiobject="u" :search="apisearch" :index="i+1" v-show="searhState(u)">
                              </methods>
                        </dd>
                        <dd v-if="apilist.length<1" class="noapi">
                              <span v-if="error==''">没有接口信息</span>
                              <span v-else>{{error}}</span>
                        </dd>
                       
                  </dl>
                  <footer>郑州微厦计算机科技有限公司</footer>
            </menu>
            <context id="context">
                  <h1 v-on:click="helpshow=!helpshow">ViewData RESTful API 接口方法使用说明<span
                              :class="helpshow ? 'show' : 'hidden'"><i class="el-icon-caret-bottom"></i></span> </h1>
                  <div class="homepage">
                        <div class="method" v-if="method!=null">
                              <attr><b>特性：</b>
                                    <span v-for="item in method.Attrs">[{{item.Name}}
                                          <i v-show='item.Ignore'>
                                                (Ignore={{item.Ignore}})</i>
                                          <i v-show='item.Expires>0' title='缓存过期时间'>
                                                (Expires={{item.Expires}})</i>] </span>
                                    <span v-if="method.Attrs.length<1">无</span>
                              </attr>
                              <div @dblclick="copyApipath(method.ClassName,method.Name)" class="name"
                                    v-html="method.ClassName +'.'+method.Name">
                                    <para>{{parameter}}</para>
                              </div>
                              <intro><b>摘要：</b>{{method.Intro}}</intro>
                              <params>
                                    <table cellspacing="0" cellpadding="0" border="0" v-show="method.Paras.length>0">
                                          <tr>
                                                <th width="40">#</th>
                                                <th width="100">参数</th>
                                                <th width="110">测试值</th>
                                                <th width="160">类型</th>
                                                <th width="80">可空</th>
                                                <th>说明</th>
                                          </tr>
                                          <tr v-for="(item,index) in method.Paras">
                                                <td>{{index+1}}</td>
                                                <td>{{item.Name}}</td>
                                                <td><input type="text" :name="item.Name"
                                                            v-on:input.prevent="teststring()" :datatype="item.Type" />
                                                </td>
                                                <td>{{item.Type.substring(item.Type.indexOf('.')+1)}}</td>
                                                <td>{{item.Nullable}}</td>
                                                <td>{{item.Intro}}</td>
                                          </tr>
                                    </table>
                              </params>
                              <remarks v-if='method.Remarks.length>0'><b>备注：</b>
                                    <div>
                                          <pre>{{method.Remarks}}</pre>
                                    </div>
                              </remarks>
                              <return><b>返回：</b>
                                    <span class="type">{{method.Return.Type}}</span>
                                    <div class="intro" v-if="method.Return.Intro.length>0">
                                          <pre>{{method.Return.Intro}}</pre>
                                    </div>
                              </return>
                              <example v-if='method.Example.length>0'><b>示例：</b>
                                    <pre>{{method.Example}}</pre>
                              </example>

                        </div>
                        <div class="testbox" v-if="method!=null" remark="测试接口">
                              <div class="test-tit">
                                    <div class="test-func">HTTP方法：
                                          <select id="httppre" v-on:change="teststring()">
                                                <option value="get">GET</option>
                                                <option value="post">POST</option>
                                                <option value="delete">DELETE</option>
                                                <option value="put">PUT</option>
                                                <option value="patch">PATHCH</option>
                                                <option value="options">OPTIONS</option>
                                                <option value="cache">CACHE</option>
                                          </select>
                                          返回：
                                          <select id="returntype">
                                                <option value="json">JSON</option>
                                                <option value="xml">XML</option>
                                          </select>
                                    </div>
                                    <div class="test-btn">
                                          <div v-on:click="testapi">
                                                <span v-show="!loading">测试</span>
                                                <span v-show='loading'> <i class='el-icon-loading'></i> 加载中...</span>
                                          </div>
                                          <div v-on:click="btnCopyEvent">复制js脚本</div>
                                          <div v-on:click="showcode=!showcode" v-html="showcode ? '隐藏脚本' : '显示脚本'">

                                          </div>
                                    </div>
                              </div>
                              <div id="testarea">
                                    <div v-show="showcode">
                                          <span id="apiurl"></span>

                                          <pre id="teststring"></pre>


                                    </div>
                                    <pre id="testresult"></pre>

                              </div>
                        </div>
                  </div>
                  <div :style="helpshow ? '' : 'transform: scale(1, 0);opacity:0;'" class="homepage">


                        <P><b>单个访问</b> </P>
                        <pre>
      $api.get('Account/Current').then(function(req){
            if(req.data.success){
                  var result=req.data.result;
                  //...
            }else{
                  throw req.data.message;
            }
      }).catch(function (err) {
            alert(err);
            console.error(err);
      });</pre>
                        <P><b>批量访问</b> </P>
                        <pre>
      $api.bat(
            $api.post('Customer/ForID', { 'id': th.formData.Ct_ID }), 
            $api.get("Agent/ForID", { 'id': th.formData.Ag_ID }) 
      ).then(axios.spread(function (customer, agent) {
            //判断结果是否正常
           for (var i = 0; i < arguments.length; i++) {
                    if (arguments[i].status != 200)
                        console.error(arguments[i]);
                    var data = arguments[i].data;
                    if (!data.success && data.exception != '') {
                        console.error(data.exception);
                        throw data.message;
                    }
                }
                //获取结果
                var cus = customer.data.result;
                var agt = agent.data.result;            
      })).catch(function (err) {
            console.error(err);
      }); </pre>
                        <P><b>本地缓存</b> </P>
                        <pre>
      //缓存20分钟，数值可以为空，默认是10分钟
      $api.cache('Account/Current:20').then(function(req){
            if(req.data.success){
                  var result=req.data.result;
                  //...
            }else{
                  throw req.data.message;
            }
      }).catch(function (err) {
            alert(err);
            console.error(err);
      });
      //更新缓存
      $api.cache('Account/Current:update');
      //清除缓存
      $api.cache('Account/Current:clear');
</pre>
                  </div>
            </context>

      </section>
      <script type="text/javascript" src="Scripts/index.js"></script>
</body>

</html>